main{
  final Server server=new Server();
  if (args.length == 0 || "start".equalsIgnoreCase(args[0])) {
    server.startDeamon();
 else   if ("stop".equalsIgnoreCase(args[0])) {
    server.stopDeamon();
}
startDeamon{
  Thread daemonThread=new Thread(new Runnable(){
  daemonThread.start();
  try {
    log.log(Level.SEVERE,"",e);
  JMXServer server=container.instance().select(JMXServer.class).get();
  MBeanServer mserver=server.getMBeanServer();
  try {
    mserver.registerMBean(new ServerStop(),new ObjectName(OBJECTNAME));
    log.log(Level.SEVERE,"",e);
}
run{ }
stopDeamon{
    ServerConfig serverConfig=readConfig();
    JMXServiceURL url=JMXServer.buildJMXAddress(serverConfig);
    JMXConnector jmxc=JMXConnectorFactory.connect(url,null);
    MBeanServerConnection jmxConnection=jmxc.getMBeanServerConnection();
    ServerStopMBean stopServer=JMX.newMBeanProxy(jmxConnection,new ObjectName(OBJECTNAME),ServerStopMBean.class);
 catch (  Exception e) {
    log.log(Level.SEVERE,"",e);
}
start{
  weld=new Weld();
  container=weld.initialize();
}
stop{
  weld.shutdown();
}
getBeanManager{
  return container.getBeanManager();
}
getBeanInstance{
  Set<Bean<?>> beans=container.getBeanManager().getBeans(clazz,new AnnotationLiteral<Any>(){
  if (beans.size() > 0) {
    Bean<C> bean=(Bean<C>)beans.iterator().next();
    CreationalContext<C> ctx=container.getBeanManager().createCreationalContext(bean);
    return (C)container.getBeanManager().getReference(bean,clazz,ctx);
}
createEvent{
  return container.event();
}
readConfig{
  String configName=System.getProperty("ode.config");
  if (configName == null) {
    configName="META-INF/" + configName + ".xml";
  ClassLoader currentCL=Thread.currentThread().getContextClassLoader();
  InputStream is=currentCL.getResourceAsStream(configName);
      JAXBElement<ServerConfig> element=(JAXBElement<ServerConfig>)u.unmarshal(is);
 catch (    JAXBException je) {
}
shutdown{ }
shutdown{
  Thread shutdownThread=new Thread(new Runnable(){
,"ODE Shutdown Thread");
  shutdownThread.start();
}
run{
}
